home *** CD-ROM | disk | FTP | other *** search
- package icontrols;
-
- import com.ms.wd.ui.Graphics;
- import com.ms.wd.ui.Image;
- import com.ms.wd.ui.Point;
- import com.ms.wd.ui.Rectangle;
-
- public class ImageDisplayer {
- public static final int ALIGN_LEFT = 1;
- public static final int ALIGN_RIGHT = 2;
- public static final int ALIGN_HCENTER = 4;
- public static final int ALIGN_TOP = 16;
- public static final int ALIGN_BOTTOM = 32;
- public static final int ALIGN_VCENTER = 64;
- public static final int ALIGN_NONE = Integer.MIN_VALUE;
- private int m_nAlign = Integer.MIN_VALUE;
- private boolean m_bStretch = false;
-
- public void paintIn(Graphics g, Rectangle bounds, Rectangle clipRect, Image img) {
- this.paintIn(g, bounds, clipRect, img, (Point)null);
- }
-
- public void paintIn(Graphics g, Rectangle bounds, Rectangle clipRect, Image img, Point imageSize) {
- if (this.m_bStretch) {
- g.drawImage(img, bounds.x, bounds.y, bounds.width, bounds.height, true);
- } else {
- Point pointImageSize = imageSize;
- if (imageSize == null) {
- pointImageSize = img.getSize();
- }
-
- int nXLoc = bounds.x;
- int nYLoc = bounds.y;
- if ((this.m_nAlign & 2) != 0) {
- nXLoc = bounds.x + bounds.width - pointImageSize.x;
- } else if ((this.m_nAlign & 4) != 0) {
- nXLoc = bounds.x + (bounds.width - pointImageSize.x) / 2;
- }
-
- if ((this.m_nAlign & 32) != 0) {
- nYLoc = bounds.y + bounds.height - pointImageSize.y;
- } else if ((this.m_nAlign & 64) != 0) {
- nYLoc = bounds.y + (bounds.height - pointImageSize.y) / 2;
- }
-
- g.drawImage(img, nXLoc, nYLoc);
- }
-
- }
-
- public void setStretch(boolean bStretch) {
- this.m_bStretch = bStretch;
- }
-
- public boolean isStretch() {
- return this.m_bStretch;
- }
-
- public void setAlignment(int nAlign) {
- this.m_nAlign = nAlign;
- }
-
- public int getAlignment() {
- return this.m_nAlign;
- }
- }
-